var url = location.href.split("&code")[0];
//url = encodeURIComponent(url);
//var name = $("#nickName").text();
//获取分享页面的title作为分享朋友圈的内容
//<div style='display: none;' class='wxshare;' data-info='{$config}'></div>
var tit = $("title").text();
var data =$(".wxshare").data("info");

var vipcode = GetURL("vipcode");
var address;
var obj = getsign();
obj.vip_code = vipcode;
$.post(myPath+"api/user/getUserByVipCode",obj,function(e){
  var data = JSON.parse(e);
  address = data.data.address;
  // address = 'http://www.mzdykt.cn/static/web/images/minlogo.png'
})

  wx.config({  
      debug: false,  
      appId: data.appId,  
      timestamp: data.timestamp,  
      nonceStr: data.nonceStr,  
      signature: data.signature,          
      jsApiList: [  
          'checkJsApi',  
          'onMenuShareTimeline',
          'onMenuShareAppMessage',
          'onMenuShareQQ' 
      ]  
  }); 
  wx.error(function (res) {
      if(res.errMsg!='config.ok'){
          alert("微信接口错误："+res.errMsg);
      }
  });

  wx.ready(function () {  
   	wx.onMenuShareTimeline({
      title: tit,
      link: url,
      imgUrl: address,
      trigger: function (res) {
        //alert('用户点击分享到朋友圈');
      },
      success: function (res) {
        alert('已分享');
      },
      cancel: function (res) {
        alert('已取消');
      },
      fail: function (res) {
        alert(JSON.stringify(res));
      }
    }); 
    wx.onMenuShareQQ({
	    title: tit, // 分享标题
	    desc: '下载就送奖学金、系列课会员，诚意满满，最高抽取6666奖学金的大红包，边学习，边收益', // 分享描述
	    link: url, // 分享链接
	    imgUrl: address, // 分享图标
	    success: function () { 
	    	alert('已分享');
	    },
	    cancel: function () { 
	    	alert('已取消');
	    }
    });
   	wx.onMenuShareAppMessage({
      title: tit, // 分享标题
      desc: "下载就送奖学金、系列课会员，诚意满满，最高抽取6666奖学金的大红包，边学习，边收益", // 分享描述
      link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
      imgUrl: address,
      trigger: function (res) {
      //  alert('用户点击发送给朋友');
      },
      success: function (res) {
        alert('已分享');
      },
      cancel: function (res) {
        alert('已取消');
      },
      fail: function (res) {
        alert(JSON.stringify(res));
      }
    });

  }); 